package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:
 * Date: 2024-06-02
 * Time: 12:15
 */
public class Test {
    public static void func(Animal animal){
        animal.eat();
    }

    public static void main(String[] args) {
        Animal animal = new Bird("小鸟",4);
        Bird bird = (Bird) animal;
        bird.fly();
        System.out.println("========");
        Animal animal1 =new Dog("单身狗",6);
        if(animal1 instanceof Bird) {
            Bird bird1 = (Bird) animal1;
            bird1.fly();
        }else{
            System.out.println("animal1 instanceof Bird not !!!");
        }
    }
    public static void main2(String[] args) {
        Dog dog = new Dog("旺财",5);
        func(dog);
        System.out.println("=======");
        Bird bird = new Bird("小鸟",6);
        func(bird);
    }
    public static void main1(String[] args) {
        Animal animal = new Dog("旺财",5);
        animal.eat();
    }
}
